using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CharactersCreater : MonoBehaviour
{
    [SerializeField]
    public List<CharacterResources> list = new List<CharacterResources>();

    private void Start()
    {
        
        for (int i = 0; i < list.Count; i++)
        {
            GameObject instantiateObj;
            instantiateObj =Instantiate(list[i].prefab, list[i].position);
            if(list[i].so.characterID==0)
            {
                FightController.Instance.playerDataHolder.Add(instantiateObj.GetComponent<CharacterDataHolder>());
            }
            else
            {
                FightController.Instance.enemyDataHolder.Add(instantiateObj.GetComponent<CharacterDataHolder>());
                FightController.Instance.enemyAttackDataHoulder.Add(instantiateObj.GetComponent<EnemyAttackDataHolder>());
            }
            instantiateObj.GetComponent<CharacterDataHolder>().characterData.ReadFromSO(list[i].so);//so记录的是角色初始状态，在创建的时候读入赋值给角色，角色其他时候要传啥咋样传都可以，characterDataHolder里面有读characterData的方法，也有每一个characterData里单独的属性可以get和set
        }
    }
}
